package com.test.com.bluetoothchatandroid.activity;

import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.widget.ExpandableListView;
import android.widget.TextView;

import com.test.com.bluetoothchatandroid.R;
import com.test.com.bluetoothchatandroid.adapter.ExpandAdapter;
import com.test.com.bluetoothchatandroid.base.BaseActivity;
import com.test.com.bluetoothchatandroid.entity.ExpandDataBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class ExpandListActivity extends BaseActivity {

	@BindView(R.id.expand_listView)
	ExpandableListView expandListView;
	@BindView(R.id.center_title)
	TextView centerTitle;
	@BindView(R.id.toolbar)
	Toolbar toolbar;

	private ExpandAdapter mAdapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_expand_list);

		ButterKnife.bind(this);

		initView();
	}

	private void initView() {
		centerTitle.setText("折叠列表展示");
		setToolbar(toolbar);

		List<ExpandDataBean> list = new ArrayList<>();
		for (int i = 0; i < 10; i++) {
			ExpandDataBean bean = new ExpandDataBean();
			bean.outerName = "第" + i + "个group";
			bean.outerId = i;
			List<ExpandDataBean.ExpandInnerBean> list1 = new ArrayList<>();
//			ExpandDataBean.ExpandInnerBean  ite = bean.new ExpandInnerBean();
			for (int j = 0; j < 3; j++) {
				ExpandDataBean.ExpandInnerBean item = bean.new ExpandInnerBean();
				item.innerId = j;
				item.innerName = "第" + i + "个group下的" + "--第" + j + "个item";
				list1.add(item);
			}
			//  实例化了解一下
			bean.innerList = new ArrayList<>();
			bean.innerList.addAll(list1);
			list.add(bean);
		}
		mAdapter = new ExpandAdapter(this.mContext);
		expandListView.setAdapter(mAdapter);
		mAdapter.setGroupInfoList(list);
//		mAdapter.setGroupInfoList(list);


	}
}
